<?xml version="1.0" encoding="utf-8"?>
<ASQueryTemplate xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<Server>carlrx64</Server>
	<Database>REAL Warehouse Sample V6 MT</Database>
	<Cube>Real Warehouse</Cube>
	<Queries>
		<!-- 0 -->
		<Query>
			SELECT { DESCENDANTS( |time_year|, -- [Time].[Calendar].[Calendar Year].[2004]
			[Time].[Calendar].[Calendar Week] ) } ON COLUMNS ,
			{ [Measures].[On Hand Qty], [Measures].[Model Qty] } ON ROWS
			FROM [REAL Warehouse]
			WHERE ( [Customer].[By Geography].[All],
			(|item_item|), -- ([Item].[By Category].[Item].&amp;[671711]),
			[Replen Strategy].[Replen Strategy].[All],
			(|geo_district|) -- ([Store].[Geography].[District].&amp;[56]) )
			CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 1 -->
		<Query>
			SELECT { (|geo_district|), -- ([Store].[Geography].[District].&amp;[17]),
			(|geo_district|), -- ([Store].[Geography].[District].&amp;[17]),
			(|geo_district|) -- ([Store].[Geography].[District].&amp;[17])
			} ON COLUMNS ,
			DESCENDANTS ( |time_year|, -- [Time].[Calendar].[2004]
			[Time].[Calendar].[Calendar Month] ) ON ROWS
			FROM [REAL Warehouse]
			WHERE ( [Measures].[cAvg Retail] )
			CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 2 -->
		<Query>
			SELECT  (|time_month|) -- ([Time].[Calendar].[Calendar Month].&amp;[2]&amp;[2004])
			ON COLUMNS ,
			[Store].[Months Since Opened].[Months Since Opened].members ON ROWS
			FROM [REAL Warehouse]
			WHERE ( (|geo_district|), -- ([Store].[Geography].[District].&amp;[17]),
			[Measures].[cAvg Retail] )
			CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 3 -->
		<Query>
			SELECT { [Measures].[cAvg Retail] , [Measures].[Sales Qty] } ON COLUMNS ,
			NON EMPTY DESCENDANTS( (|item_category|), -- ([Item].[By Category].[Category].&amp;[034B]),
			[Item].[By Category].[Item] ) ON ROWS
			FROM [REAL Warehouse]
			WHERE ( (|geo_district|), -- ([Store].[Geography].[District].&amp;[17]),
			(|time_month|) ) -- ([Time].[Calendar].[Calendar Month].&amp;[2]&amp;[2004])
			CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 4 -->
		<Query>
			SELECT { [Measures].[Sales Qty] } ON COLUMNS ,
			NON EMPTY { [Item].[All],
			DESCENDANTS( [Item].[All], [Item].[By Category].[Subject] ) } ON ROWS
			FROM [REAL Warehouse]
			WHERE ( (|geo_district|), -- ([Store].[Geography].[District].&amp;[17]),
			(|time_fiscal_period|) ) -- [Time].[Fiscal].[Fiscal Period].&amp;[2]&amp;[2004]
			CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 5 -->
		<!-- Note the district is different, do we want to make 2 template parameters? -->
		<Query>
			WITH MEMBER [Measures].[Pct of Qty Vendor] as
			'[Measures].[Sales Qty]/([Measures].[Sales Qty], [Item].[All])', FORMAT_STRING = '0.000%'
			SELECT NON EMPTY order ([Item].[Purchase Vendor].members,
			([Measures].[Sales Qty]), DESC ) * { [Measures].[Sales Qty],
			[Measures].[Sale Amt],
			[Measures].[Pct of Qty Vendor] } ON COLUMNS ,
			NON EMPTY { ORDER( { [Item].[All Item],
			DESCENDANTS( [Item].[All], [Item].[By Category].[Subject] ) },
			( [Measures].[Sales Qty] ), DESC ) } ON ROWS
			FROM [REAL Warehouse]
			WHERE ( (|time_fiscal_week|, -- [Time].[Fiscal].[Fiscal Week].&amp;[46]&amp;[2004]),
			(|geo_district|)) -- ([Store].[Geography].[District].&amp;[28]) )
		</Query>

		<!-- 6 -->
		<Query>
		WITH MEMBER [Measures].[Pct of Qty Vendor] as
		'[Measures].[Sales Qty]/([Measures].[Sales Qty], [Item].[Purchase Vendor].[All])', FORMAT_STRING = '0.000%'
		SELECT NON EMPTY { { {
			(|time_fiscal_week|) --([Time].[Fiscal].[Fiscal Week].&amp;[46]&amp;[2004])
		} * { [Measures].[Sales Qty], [Measures].[Sale Amt], [Measures].[Pct of Qty Vendor] } } } ON COLUMNS ,
		NON EMPTY { ORDER( { [Vendor].[Purchase Vendor].[All], [Item].[Purchase Vendor].members }, (
			(|time_fiscal_week|), --([Time].[Fiscal].[Fiscal Week].&amp;[46]&amp;[2004]),
		[Measures].[Sale Amt] ), BDESC ) } ON ROWS
		FROM [REAL Warehouse]
		WHERE ( (|geo_district|)) -- ([Store].[Geography].[District].&amp;[17]) )
		CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 7 -->
		<Query>
		WITH SET [Rolling 24 Weeks] AS
		'LastPeriods(24,
			(|time_fiscal_week|))' --([Time].[Fiscal].[Fiscal Week].&amp;[7]&amp;[2004])
		SELECT NON EMPTY [Rolling 24 Weeks] ON COLUMNS ,
		NON EMPTY { [Measures].[Sales Qty],
		[Measures].[Model Qty],
		[Measures].[On Hand Qty],
		[Measures].[On Order Qty],
		[Measures].[Total DC Qty] } ON ROWS
		FROM [REAL Warehouse]
		WHERE ( (|geo_region|) )	-- [Store].[Geography].[Region].&amp;[2]) )
		CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>


		<!-- 8 -->
		<!-- Note the district is different, do we want to make 2 template parameters? -->
		<Query>
		WITH SET [Rolling 24 Weeks] AS
		'LastPeriods(24,
			(|time_fiscal_week|))' -- ([Time].[Fiscal].[Fiscal Week].&amp;[7]&amp;[2004])
		SELECT NON EMPTY [Rolling 24 Weeks] ON COLUMNS ,
		{ [Measures].[Days In Stock],
		[Measures].[Model Qty],
		[Measures].[On Hand Qty],
		[Measures].[Sales Qty],
		[Measures].[Return Qty] } ON ROWS
		FROM [REAL Warehouse]
		WHERE ( (|geo_district|)) -- ([Store].[Geography].[District].&amp;[56]) )
		CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 9 -->
		<Query>
			SELECT { [Measures].[On Hand Qty], [Measures].[Sales Qty] } ON COLUMNS ,
			{ TOPCOUNT( { DESCENDANTS( [Item].[By Category].[Product].[Book], [Item].[By Category].[Subject] ) }, 100, ( [Measures].[On Hand Qty] ) ) } ON ROWS
			FROM [REAL Warehouse]
			WHERE ( (|geo_region|),	-- [Store].[Geography].[Region].&amp;[3]),
			(|time_fiscal_period|)) -- ([Time].[Fiscal].[Fiscal Period].&amp;[2]&amp;[2004]) )
		CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 10 -->
		<Query>
			WITH SET [Rolling 24 Weeks] AS
			'LastPeriods(24,
			(|time_fiscal_week|))' -- ([Time].[Fiscal].[Fiscal Week].&amp;[7]&amp;[2004])
			SELECT NON EMPTY [Rolling 24 Weeks] ON COLUMNS ,
			{ [Measures].[Days In Stock], [Measures].[Model Qty], [Measures].[On Hand Qty], [Measures].[Sales Qty], [Measures].[Return Qty] } ON ROWS
			FROM [REAL Warehouse]
			WHERE ( (|geo_district|)) -- ([Store].[Geography].[District].&amp;[56]) )
			CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 11 -->
		<Query>
			SELECT { [Measures].[Sales Qty], [Measures].[Model Qty] } ON COLUMNS ,
			NON EMPTY { DESCENDANTS( [Store].[Geography].[District], , LEAVES ) } ON ROWS
			FROM [REAL Warehouse]
			WHERE ( [Store].[Status Desc].[Active], (|item_dept|) , -- ([Item].[Dept].&amp;[AUDIO])
			(|time_fiscal_week|)) -- ([Time].[Fiscal].[Fiscal Week].&amp;[7]&amp;[2004]) )
		</Query>

		<!-- 12 -->
		<Query>
			SELECT { [Measures].[Sales Qty], [Measures].[Model Qty] } ON COLUMNS ,
			NON EMPTY { { { DESCENDANTS( [Replen Strategy].[Replen Strategy].[All], [Replen Strategy].[Replen Strategy].[Strategy] ) } * { DESCENDANTS( [Store].[Geography].[All], , LEAVES ) } } } ON ROWS
			FROM [REAL Warehouse]
			WHERE ( [Store].[Status Desc].[Active], (|item_dept|) , -- ([Item].[Dept].&amp;[AUDIO])
			(|time_fiscal_week|)) -- ([Time].[Fiscal].[Fiscal Week].&amp;[7]&amp;[2004]) )
		CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>


		<!-- 13 -->
		<Query>
		WITH MEMBER [Measures].[Pct All Item Contribution] AS
		'([Measures].[Sale Amt])/([Measures].[Sale Amt], [Item].[All])', FORMAT_STRING = '0.0%'
		MEMBER [Measures].[Pct Parent Contribution] AS
		'([Measures].[Sale Amt])/([Measures].[Sale Amt], [Item].[By Category].CurrentMember.Parent )', FORMAT_STRING = '0.0%'
		SELECT NON EMPTY { [Measures].[Pct All Item Contribution], [Pct Parent Contribution] } ON COLUMNS ,
		NON EMPTY { ORDER( { DESCENDANTS( [Item].[All], [Item].[By Category].[Subject] ) }, ( [Measures].[Pct All Item Contribution] ), BDESC ) } ON ROWS
		FROM [REAL Warehouse]
		WHERE (
			(|time_fiscal_period|), -- ([Time].[Fiscal].[Fiscal Period].&amp;[2]&amp;[2004]),
			(|geo_district|)) -- ([Store].[Geography].[District].&amp;[17]) )
		CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 14 -->
		<Query>
		WITH MEMBER [Measures].[Sales Per SqFt] AS
		'iif( val([Store].[Geography].CurrentMember.Properties("Square Feet")) > 10,
		([Measures].[Sale Amt])/val([Store].[Geography].CurrentMember.Properties("Square Feet")), NULL)',
		FORMAT_STRING = '$0.00'
		MEMBER [Measures].[SqFt] AS
		'val([Store].[Geography].CurrentMember.Properties("Square Feet"))'
		MEMBER [Measures].[Sales Per LinFt] AS
		'iif( val([Store].[Geography].CurrentMember.Properties("Linear Ft")) > 10,
		([Measures].[Sale Amt])/val([Store].[Geography].CurrentMember.Properties("Linear Ft")), NULL)',
		FORMAT_STRING = '$0.00'
		MEMBER [Measures].[LinFt] AS 'val([Store].[Geography].CurrentMember.Properties("Linear Ft"))'
		SELECT { [Measures].[Sale Amt], [Measures].[Sales Qty], [Measures].[SqFt], [Measures].[Sales Per SqFt], [Measures].[LinFt], [Measures].[Sales Per LinFt] } ON COLUMNS ,
		/*non empty [Store].[District].[District].members * */
		{ ORDER( { TOPCOUNT( { DESCENDANTS( [Store].[All], [Store].[Geography].[Store] ) }, 10, ( [Measures].[Sales Per SqFt] ) ) }, ( [Measures].[Sales Per SqFt] ), BDESC ) } ON ROWS
		FROM [REAL Warehouse]
		WHERE ( (|time_fiscal_period|) ) -- ([Time].[Fiscal].[Fiscal Period].&amp;[2]&amp;[2004]) )
		CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

		<!-- 15 -->
		<Query>
		WITH MEMBER [Measures].[cPct of Sbj Qty per Vndr] AS
		'([Measures].[Sale Amt])/([Measures].[Sale Amt], [Item].[Purchase Vendor].[All] )', FORMAT_STRING = '0.0%'
		SELECT { [Item].[Dept].[HARDCOVER], [Item].[Dept].[JUVENILE],
		[Item].[Dept].[MASS MARKET], [Item].[Dept].[TRADE PAPERBACK] } * {[Measures].[Sale Amt],
		[Measures].[cPct of Sbj Qty per Vndr]} ON COLUMNS,
		NON EMPTY TOPCOUNT( [Item].[Purchase Vendor].members, 20, [Measures].[Sale Amt] ) ON ROWS
		FROM [REAL Warehouse]
		WHERE ( (|time_fiscal_period|)) -- ([Time].[Fiscal].[Fiscal Period].&amp;[2]&amp;[2004]) )
		CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, ACTION_TYPE
		</Query>

	</Queries>
	<Tokens>
		<!-- 
			item_category = item_item.parent.parent
			item_item = [Item].[By Category].[Item].members

			item_dept = [Item].[By Dept].[Dept].members

			geo_region = geo_district.parent
			geo_district = [Store].[Geography].[District].members

			time_year = time_month.parent.parent
			time_month = [Time].[Calendar].[Calendar Month].members

			time_fiscal_period = time_fiscal_week.parent
			time_fiscal_week = [Time].[Fiscal].[Fiscal Week].members
			
			Note that we want the fiscal week that intersects the calendar month.
			Pick the token that is more fine grained, for more even distribution.
			time_fiscal_week is randomly selected from set of 51.
			time_month is determined uniquely (only 1) from time_fiscal_week.
			
			Here is MDX that gets generated.
			with member [measures].[__TESTTEST__] as 'null' 
			select NonEmpty( 
				[Time].[Calendar].[Calendar Month].members,
				{[Time].[Fiscal].[Fiscal Week].&[34]&[2004]} /* generated */
				* [Measures].[Sale Amt] )
			on 0 from [Real Warehouse] where [measures].[__TESTTEST__]
		-->
		<Token>
			<Name>time_year</Name>
			<MinQuantity>1</MinQuantity>
			<MaxQuantity>1</MaxQuantity>
			<Tuple Set="|time_month|.parent.parent" />
		</Token>
		<Token>
			<Name>time_month</Name>
			<MinQuantity>1</MinQuantity>
			<MaxQuantity>1</MaxQuantity>
			<!-- Tuple Set="[Time].[Calendar].[Calendar Month].members" / -->
			<!-- This gives the set for which data exists. Important because our database subset only has some partitions processed. -->
			<!-- Tuple Set="NonEmpty( [Time].[Calendar].[Calendar Month].members, [Measures].[Sale Amt] )" / -->
			<Tuple Set="NonEmpty( [Time].[Calendar].[Calendar Month].members, {|time_fiscal_week|} * [Measures].[Sale Amt] )" />
		</Token>
		<Token>
			<Name>time_fiscal_period</Name>
			<MinQuantity>1</MinQuantity>
			<MaxQuantity>1</MaxQuantity>
			<Tuple Set="|time_fiscal_week|.parent" />
		</Token>
		<Token>
			<Name>time_fiscal_week</Name>
			<MinQuantity>1</MinQuantity>
			<MaxQuantity>1</MaxQuantity>
			<!-- Tuple Set="NonEmpty( [Time].[Fiscal].[Fiscal Week].members, [Time].[Calendar].[Calendar Month].members * [Measures].[Sale Amt] )" / -->
			<!-- This gives the set for which data exists, matching the |time_month| hierarchy. -->
			<!-- Tuple Set="NonEmpty( [Time].[Fiscal].[Fiscal Week].members, {|time_month|} * [Measures].[Sale Amt] )" / -->
			<Tuple Set="NonEmpty( [Time].[Fiscal].[Fiscal Week].members, [Measures].[Sale Amt] )" />
		</Token>
		<Token>
			<Name>geo_region</Name>
			<MinQuantity>1</MinQuantity>
			<MaxQuantity>1</MaxQuantity>
			<Tuple Set="|geo_district|.parent" />
		</Token>
		<Token>
			<Name>geo_district</Name>
			<MinQuantity>1</MinQuantity>
			<MaxQuantity>1</MaxQuantity>
			<Tuple Set="NonEmpty( [Store].[Geography].[District].members, {|time_month|} * [Measures].[Sale Amt] )" />
		</Token>
		<Token>
			<Name>item_category</Name>
			<MinQuantity>1</MinQuantity>
			<MaxQuantity>1</MaxQuantity>
			<Tuple Set="|item_item|.parent.parent" />
		</Token>
		<Token>
			<Name>item_item</Name>
			<MinQuantity>1</MinQuantity>
			<MaxQuantity>1</MaxQuantity>
			<!-- This gives the top-selling items for a certain year. We limit by year just to make the query faster. -->
			<Tuple Set="TOPCOUNT( [Item].[By Category].[Item].members, 4000, ( [Measures].[Sale Amt], [Time].[Calendar].[Calendar Year].[2004] ) )" />
		</Token>
		<Token>
			<Name>item_dept</Name>
			<MinQuantity>1</MinQuantity>
			<MaxQuantity>1</MaxQuantity>
			<!-- We observed in query 15 a hardcoded set.  But we are not sure if we should use that or everything.  -->
			<!-- Tuple Set="{[Item].[Dept].[HARDCOVER], [Item].[Dept].[JUVENILE], [Item].[Dept].[MASS MARKET], [Item].[Dept].[TRADE PAPERBACK]}" -->
			<Tuple Set="[Item].[Dept].members" />
		</Token>
	</Tokens>
	<RandomSeed />
	<ClientFile Name="CarlR_REAL_sample.XML" StartingNumber="1" NumOfFiles="2000" DuplicateRetryCount="5"/>	
</ASQueryTemplate>
